//
//  DHAdvCell.m
//  精品酒店
//
//  Created by DIANGHONG on 2018/5/7.
//  Copyright © 2018年 DIANGHONG. All rights reserved.
//

#import "DHAdvCell.h"
@interface DHAdvCell()<SDCycleScrollViewDelegate>
@property(nonatomic ,strong)SDCycleScrollView *AdvView;  // 广告图片轮播器
@end

@implementation DHAdvCell



- (void)setBanners:(NSArray<DHBannerModel *> *)banners{
    _banners = banners;
    
    self.AdvView.imageURLStringsGroup = [banners valueForKey:@"adv_image"];
}

- (SDCycleScrollView *)AdvView{
    if (!_AdvView) {
        _AdvView = [SDCycleScrollView cycleScrollViewWithFrame:self.bounds delegate:self placeholderImage:nil];
    }
    return _AdvView;
}


- (void)layoutSubviews{
    [super layoutSubviews];
    [self.contentView addSubview:self.AdvView];
}

#pragma mark: - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    
    NSAssert(self.advCellClickBlock != nil, @"self.advCellClickBlock 不能为nil");
    
    self.advCellClickBlock(self.banners[index].adv_url);
}

@end
